<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('监督批次列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li class="select-time">
                                <p>日期：</p>
                                <input type="text" class="time-input" id="beginDate" placeholder="开始日期" name="beginDate"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endDate" placeholder="结束日期" name="endDate"/>
                            </li>
                            <li>
                                <p>机构：</p>
                                <input type="text" name="orgId" id="orgId"/>
                            </li>
                            <li>
                                <p>监督员：</p>
                                <input type="text" name="auditorId" id="auditorId"/>
                            </li>
                            <li>
                                <p>监督类型：</p>
                                <select id="batchType" name="batchType" class="form-control select2-single">
                                    <option value="">所有</option>
                                    <option th:each="auType:${auTypes}" th:value="${auType.code}" th:text="${auType.code+'-'+auType.name}"></option>
                                </select>
                            <li>
                            <li>
                                <p>监督状态：</p>
                                <select name="state" id="state" th:with="type=${@dict.getType('paea_au_batch_state')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
<!--                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="paeaAubatch:paeaAubatch:add">-->
<!--                    <i class="fa fa-plus"></i> 添加-->
<!--                </a>-->
<!--                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="paeaAubatch:paeaAubatch:edit">-->
<!--                    <i class="fa fa-edit"></i> 修改-->
<!--                </a>-->
<!--                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="paeaAubatch:paeaAubatch:remove">-->
<!--                    <i class="fa fa-remove"></i> 删除-->
<!--                </a>-->
<!--                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="paeaAubatch:paeaAubatch:export">-->
<!--                    <i class="fa fa-download"></i> 导出-->
<!--                 </a>-->
                <a class="btn btn-warning" onclick="reAuditItemInfo()">
                    <i class="fa fa-download"></i> 质量检查
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "oms/paeaAuBatch";
        var stateDatas = [[${@dict.getType('paea_au_batch_state')}]];
        $(function() {
            var options = {
                url: prefix + "/list",
                exportUrl: prefix + "/export",
                modalName: "监督批次",
                //启用跳转至指定页
                showPageGo: true,
                //启用点击选中行
                clickToSelect: true,
                columns: [{
                    radio: true
                },
                {
                    field : 'id',
                    title : 'id',
                    visible: false
                },
                {
                    field : 'trDate',
                    title : '日期'
                },
                {
                    field : 'orgId',
                    title : '机构'
                },
                {
                    field : 'auditorId',
                    title : '监督员'
                },
                {
                    field : 'batchType',
                    title : '监督类型'
                },
                {
                    field : 'auItemNum',
                    title : '监督数量'
                },
                {
                    field : 'finishNum',
                    title : '完成数量'
                },
                {
                    field : 'state',
                    title : '监督状态',
                    align: 'center',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(stateDatas, value);
                    }
                },
                {
                    field : 'reAuditor',
                    title : '质检员'
                },
                {
                    field : 'startDate',
                    title : '监督开始时间'
                },
                {
                    field : 'finishDate',
                    title : '监督完成时间'
                }]
            };
            $.table.init(options);
        });

        //质量检查
        function reAuditItemInfo() {
            var x=screen.availWidth;
            var y=screen.availHeight;
            var row = $("#bootstrap-table").bootstrapTable('getSelections')[0];
            if(null==row){
                $.modal.msgWarning("请选择一条记录！");
            }else{
                var state = row.state;
                if(state == 2){
                    url = "/oms/paeaAuAuditItem/auditBatchDetail?queryFlag=normal&isViewOnly=true&arcId="+row.id;
                    window.showModalDialog(url,"","dialogWidth=" + x + "px; dialogHeight=" + y + "px; help=no; status=no; scroll=yes; resizable=no;");
                }else{
                    var beginDate = $("#beginDate").val();
                    var endDate = $("#endDate").val();
                    var orgId = $("#orgId").val();
                    var auditorId = $("#auditorId").val();
                    var state = $("#state").val();
                    var batchType = $("#batchType").val();
                    var url = ctx + "oms/paeaAuAuditItem/reAuditItemInfo?batchId="+row.id+"&beginDate="+beginDate+"&endDate="+endDate+"&orgId="+orgId
                        +"&auditorId="+auditorId+"&batchType="+batchType+"&state="+state;
                    var returnValue = window.showModalDialog(url,"质量检查","dialogWidth=" + x + "px; dialogHeight=" + y + "px; help=no; status=no; scroll=yes; resizable=no;");
                    if(null != returnValue && "" != returnValue){
                        $.modal.refresh();

                    }
                }
            }
        }
    </script>
</body>
</html>